#ifndef _CDSF_CONTROL_H_
#define _CDSF_CONTROL_H_

#include "CDSF_Includes.h"
#include "CDSF_Types.h"
#include "CDSF_ErrorCode.h"
#include "CDSF_Display.h"

typedef int SFKeyCode;

typedef unsigned int SFInputStringMode;
#define SFInputStringModeNone		0x00000000
#define SFInputStringModeMaskPinyin	0x00000001

struct _SFViewController_T_;
typedef void (*SFResponseFunction)(struct _SFViewController_T_ *this, SFScreenId screenId, SFKeyCode keyCode);

typedef struct {;
	const SFKeyCode keyCode;
	const SFResponseFunction function;
}SFResponseEntry;

typedef struct {
	const SFResponseEntry * const entries;
	const int count;
}SFResponseEntryList;

typedef struct _SFViewController_T_ {
	SFView * const view;
	void (* const viewWillAppear)(struct _SFViewController_T_ *this, SFScreenId screenId);
	void (* const viewWillDisappear)(struct _SFViewController_T_ *this, SFScreenId screenId);
	void (* const receiveInputString)(struct _SFViewController_T_ *this, SFScreenId screenId, const char *cString, SFInputStringMode mode);
	const SFResponseEntryList responseEntryList;
}SFViewController;


SFInjection SFCode SFControlReadKey(SFScreenId screenId, SFKeyCode *keyCode);
SFInjection SFCode SFControlReadInputString(SFScreenId screenId, const char **cString, SFInputStringMode *mode);

SFInjection SFViewController * const SFControlDefaultRootViewController;

extern SFViewController * SFControlGetCurrentRootViewController(SFScreenId screenId);
extern void SFControlSetCurrentRootViewController(SFScreenId screenId, SFViewController *viewController);

extern SFCode SFControlInit(SFClockRate rate);
extern SFCode SFControlDelegate(void);

#endif